<template>
  <el-dialog append-to-body :close-on-click-modal="false" :before-close="crud.cancelCU" :visible="crud.status.cu > 0" :title="crud.status.title" width="700px">
    <el-form ref="form" :model="form" :rules="rules" size="small" label-width="120px">
      <el-form-item label="定价类型" prop="priceType">
        <el-select v-model="form.priceType" filterable placeholder="请选择">
          <el-option v-for="item in dict.dict.type_price_setting" :key="item.dictValue" :label="item.dictLabel" :value="item.dictValue" />
        </el-select>
      </el-form-item>
      <el-form-item label="起始小时数" prop="priceStartHour">
        <el-input v-model="form.priceStartHour" />
      </el-form-item>
      <el-form-item label="起始价格" prop="priceStartMoney">
        <el-input v-model="form.priceStartMoney" />
      </el-form-item>
      <el-form-item label="后续每小时价格">
        <el-input v-model="form.priceAfterMoney" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="text" @click="crud.cancelCU">取消</el-button>
      <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
    </div>
  </el-dialog>
</template>

<script>
import CRUD, { form } from '@crud/crud'

const defaultForm = { id: null, hospitalId: null, hospitalName: null, priceType: null, priceStartHour: null, priceStartMoney: null, priceAfterMoney: null, priceDesc: null }
export default {
  mixins: [form(defaultForm)],
  props: {
    dict: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      hospitalId: null,
      rules: {
        priceType: [{ required: true, message: '定价类型不能为空', trigger: 'blur' }],
        priceStartHour: [{ required: true, message: '起始小时数不能为空', trigger: 'blur' }],
        priceStartMoney: [{ required: true, message: '起始价格不能为空', trigger: 'blur' }]
      }
    }
  },
  created() {
    this.hospitalId = this.$route.params.hospitalId
  },
  methods: {
    [CRUD.HOOK.beforeToCU](crud, form) {
      form.hospitalId = this.hospitalId
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  /deep/ .el-input-number .el-input__inner {
    text-align: left;
  }
</style>
